<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>出院办理</title>
    <div th:insert="user/common::head"></div>
</head>

<body class="">
<div class="wrapper ">
    <div th:insert="~{user/common::sidebar(active='patient_checkout.html')}"></div>
    <div class="main-panel">
        <!-- Navbar导航栏 -->
        <nav th:replace="~{user/common::navbar}"></nav>
        <!-- End Navbar -->
        <div class="panel-header panel-header-sm">
        </div>
        <div class="content">
            <div class="row">
                <div class="col-md-8 offset-2">
                    <div class="card">
                        <div class="card-header">
                            <h5 class="title">出院办理</h5>
                        </div>
                        <div class="card-body">
                            <form id="update_form" method="post">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <input name="patientId" type="text" hidden="hidden" th:value="${patient.getPatientId()}">
                                            <input name="inDate" type="date" hidden="" th:value="${#dates.format(patient.getInDate(),'yyyy-MM-dd')}">
                                            <label>病人姓名</label>
                                            <input name="patientName" type="text" class="form-control" placeholder="请输入病人的姓名" th:value="${patient.getPatientName()}" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>病人性别</label>
                                            <input name="patientGender" class="form-control" placeholder="选择患者性别..." th:value="${patient.getPatientGender()==1?'男':'女'}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>主要使用药物</label>
                                            <input type="text" class="form-control" th:value="${drug.getDrugName()+'：'}+${drug.getDrugPrice()}+'元/天'" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>主治医师</label>
                                            <input type="text" class="form-control" th:value="${doctor.getDoctorName()}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">

                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>入院日期</label>
                                            <input name="inDate" type="date" class="form-control" th:value="${#dates.format(patient.getInDate(),'yyyy-MM-dd')}" readonly>
                                        </div>
                                    </div>   <div class="col-md-6">
                                        <div class="form-group">
                                            <label>出院日期</label>
                                            <input name="outDate" type="date" class="form-control" th:value="${#dates.format(patient.getOutDate(),'yyyy-MM-dd')}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-4 px-1">
                                        <div class="form-group">
                                            <label>所在病房</label>
                                            <input type="text" th:value="${patient.getInpatientwardId()}" class="form-control" placeholder="选择病房" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4 px-1">
                                        <div class="form-group">
                                            <label>所在床位</label>
                                            <input type="text" class="form-control" th:value="${patient.getBedId()}+'号床'" readonly>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label th:text="${inpatientward.getInpatientwardType()}">房间消费</label>
                                            <input class="form-control" th:value="${inpatientward.getInpatientwardCost()}+'元/天'" readonly>
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="form-group">
                                            <label>诊断结果</label>
                                            <textarea name="patientResult" rows="5" cols="80" class="form-control" placeholder="请输入患者的诊断结果。" style="max-height: 200px" th:text="${patient.getPatientResult()}" readonly></textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-8 offset-3">
                                       <a class="btn-warning btn btn-lg col-4 text-white" th:href="@{/toPatientCheckout}">返回</a>
                                        <input type="button" class="btn-primary btn btn-lg col-4" data-toggle="modal" data-target="#settlementModal" value="结算">
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--底部footer-->
        <footer th:replace="~{user/common::footer}"></footer>
    </div>
</div>

<!-- Modal -->
<!--结算付款-->
<div class="modal fade shadow-none p-3 mb-5 rounded" id="settlementModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content" style="margin-top: 15rem">
            <div class="modal-header">
                <h5 class="modal-title">结算付款</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <!--注册表单-->
                <form id="result_form">

                    <span>总共住院<strong>[[${day}]]</strong>天，价格为<strong>[[${cost}]]</strong>元。</span>

                    <div class="modal-footer">
                        <div style="color: red;margin: 0 auto;" id="regTip"></div>
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">返回</button>
                        <input type="button" class="btn btn-primary" onclick="patientCheckout()" value="已支付">
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<script>
    function patientCheckout(){
        $.ajax({
            url: '/patientCheckOut',
            data: {
                'id': [[${patient.getPatientId()}]],
            },
            method: 'post',
            dataType: 'text',
            success: function (result) {
                if (result === '办理成功!') {
                    demo.showNotification('success', result);
                    $("#settlementModal").modal('hide');
                    setTimeout(function () {
                        window.location = '/toPatientCheckout'
                    }, 1000)
                    return;
                }
                demo.showNotification('danger', result);
            }
    })

    }



</script>

<!--通用footerJs-->
<script th:replace="~{user/common::footerJs}"></script>

</body>
</html>
